package org.dinner.order.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@NamedQueries({
	@NamedQuery(name="ShippingUnit.list", query="from ShippingUnit"),
})
@Table(name = "SHIPPING_UNITS")
public class ShippingUnit {
	
	@Id
	@GeneratedValue
	private int id;
	@Column(nullable = false)
	private String address;
	@OneToMany(mappedBy = "unit")
	private List<User> users = new ArrayList<User>();
	@ManyToMany
	@JoinTable(name = "UNITS_ADMINS")
	private List<User> contacts = new ArrayList<User>();
	@OneToMany(mappedBy = "unit")
	private List<Order> orders = new ArrayList<Order>();
	
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public List<User> getContacts() {
		return contacts;
	}
	public void setContacts(List<User> contacts) {
		this.contacts = contacts;
	}
	public List<Order> getOrders() {
		return orders;
	}
	public void setOrders(List<Order> orders) {
		this.orders = orders;
	}
	
	

}
